package com.example.tangjiangxu.pulltorefreshtest;

import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class MainActivity extends Activity {
    private RefreshableView rv;
    private ListView listView;
    ArrayAdapter<String> adapter;
    String[] items = {"A", "B","C", "D","E", "F","G", "H", "A", "B","C", "D","E", "F","G", "H", "A", "B","C", "D","E", "F","G", "H"};

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        rv = (RefreshableView) findViewById(R.id.rv_refreshable);
        listView = (ListView) findViewById(R.id.listview);
        adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, items);
        listView.setAdapter(adapter);
        rv.setOnRefreshListener(new RefreshableView.PullToRefreshListener() {
            @Override
            public void onRefresh() {
                try {
                    Thread.sleep(6000);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                rv.finishRefreshing();
            }
        }, -1);
    }
}
